package com.heima.common.result;

import com.heima.common.constants.MessageConstant;
import lombok.Data;

/**
 * @author Administrator
 */
@Data
public class Result {

    private Integer code;   //信息码：1：成功，0：失败
    private String msg; //信息描述
    private Object data;    //返回数据

    public static Result success(){
        Result result = new Result();
        result.setCode(MessageConstant.RESULT_SUCCESS);
        result.setMsg(MessageConstant.RESULT_SUCCESS_MSG);
        return result;
    }

    public static Result success(Object obj){
        Result result = new Result();
        result.setCode(MessageConstant.RESULT_SUCCESS);
        result.setMsg(MessageConstant.RESULT_SUCCESS_MSG);
        result.setData(obj);
        return result;
    }

    public static Result error(Object... obj){
        Result result = new Result();
        result.setCode(MessageConstant.RESULT_ERROR);
        result.setMsg(MessageConstant.RESULT_ERROR_MSG);
        result.setData(obj);
        return result;
    }
}
